local addonName,ns = ...
local DB = ns.PlateColorDB
local L = ns.L

ns.CVarFrames = {TextFrames = {},Frames = {}}--记录CVar框体
ns.Y = {}	--用于分页行数自动拓展

local addontext = ns.RCTexts(addonName)
local PCGUI = CreateFrame("Frame")
local category = Settings.RegisterCanvasLayoutCategory(PCGUI, addontext)
Settings.RegisterAddOnCategory(category)

SlashCmdList["PLATECOLOR"] = function()
	Settings.OpenToCategory(category:GetID())
end
SLASH_PLATECOLOR1 = "/pc"
SLASH_PLATECOLOR2 = "/platecolor"

ns.event("PLAYER_LOGIN", function()

--标题文本
local TiText = PCGUI:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
TiText:SetPoint("TOPLEFT",PCGUI,"TOPLEFT", 0, -10)
TiText:SetText(addontext)
TiText:SetFont(ns.fonts, 50, "OUTLINE")
--标题文本2
local TiText2 = PCGUI:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
TiText2:SetPoint("BOTTOMLEFT",TiText,"BOTTOMRIGHT", 5, 8)
TiText2:SetFont(ns.fonts, 20, "OUTLINE")
TiText2:SetText(SHOW_TARGET_CASTBAR_IN_V_KEY)
TiText2:SetVertexColor(1.0, 1.0, 1.0)

--版本信息
local versiontext = PCGUI:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
versiontext:SetPoint("TOPRIGHT", 0, 5)
versiontext:SetText("|cff00FFFF"..C_AddOns.GetAddOnMetadata(addonName,"Version"))
versiontext:SetJustifyH("RIGHT")
versiontext:SetVertexColor(0, 1, 1)


-- 创建主背景框架
local parentBackdrop = CreateFrame("Frame", "PCparentFrame", PCGUI, "BackdropTemplate")
parentBackdrop:SetSize(680, 500)
parentBackdrop:SetPoint("BOTTOMLEFT",-14,-2)
parentBackdrop:SetBackdrop({
    bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
    edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
    edgeSize = 16,
    insets = { left = 4, right = 4, top = 4, bottom = 4 },
})
parentBackdrop:SetBackdropColor(0, 0, 0, 0.5)
parentBackdrop:SetBackdropBorderColor(0.7, 0.7, 0.7)

--创建ns.tabframe分页
ns.tabframe1 = CreateFrame("Frame", nil, parentBackdrop)
ns.tabframe2 = CreateFrame("Frame", nil, parentBackdrop)
ns.tabframe3 = CreateFrame("Frame", nil, parentBackdrop)
ns.tabframe4 = CreateFrame("Frame", nil, parentBackdrop)
ns.tabframe5 = CreateFrame("Frame", nil, parentBackdrop)
ns.tabframe6 = CreateFrame("Frame", nil, parentBackdrop)
ns.tabframe7 = CreateFrame("Frame", nil, parentBackdrop)
ns.tabframe1:SetAllPoints(parentBackdrop)
ns.tabframe2:SetAllPoints(parentBackdrop)
ns.tabframe3:SetAllPoints(parentBackdrop)
ns.tabframe4:SetAllPoints(parentBackdrop)
ns.tabframe5:SetAllPoints(parentBackdrop)
ns.tabframe6:SetAllPoints(parentBackdrop)
ns.tabframe7:SetAllPoints(parentBackdrop)
--绑定到放大按钮
ns.AddClickBC(parentBackdrop,ns.tabframe1,1,72, L["基础"],42)
ns.AddClickBC(parentBackdrop,ns.tabframe2,2,72, L["颜色"])
ns.AddClickBC(parentBackdrop,ns.tabframe3,3,72, L["光环"])
ns.AddClickBC(parentBackdrop,ns.tabframe4,4,100,L["光环列表"])
ns.AddClickBC(parentBackdrop,ns.tabframe5,5,90, L["NPC列表"])
ns.AddClickBC(parentBackdrop,ns.tabframe6,6,72, NEWBIE_TOOLTIP_STOPWATCH_RESETBUTTON)--重置
ns.AddClickBC(parentBackdrop,ns.tabframe7,7,100, UPDATE..GUILD_BANK_LOG)--重置

--重载按钮
local reload = CreateFrame("Button", nil, PCGUI, "UIPanelButtonTemplate")
reload:SetText("重载")
reload:SetWidth(92)
reload:SetHeight(22)
reload:SetPoint("BOTTOMRIGHT", -132, -31)
reload:SetScript("OnClick", function()
	 ReloadUI()
end)


end)